﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>发件箱</title>
    <link href="@Url.Content("~/Areas/User/Css/msg.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Areas/User/Css/pager.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/JS/artDialog/skins/syhDialog.css")"
        rel="stylesheet" type="text/css" />
</head>
<body>
     <div class="rightbar mt10">
        <ul class="tittab">
            <li class="tcurrent">发件箱</li>
        </ul>
        <div class="action-bar mt10">
            <p class="fd-left">
                <input name="ckAll" type="checkbox" value="" class="fd-left mr5 mt3 txt3" />
                <span class="fd-left mr10">全选</span> <span class="gray-btn fd-left ml10"><a href="#"
                    class="wh01 h17" onclick="deleteMore();">删除</a></span>
            </p>
            <p class="fd-right">
                共 <b>
                    @ViewBag._Count</b> 封</p>
        </div>
        <div class="fd-clear">
        </div>
        <div class="msglists" id="msglists">
                    @foreach (var single in @Model.Rows)
                    {
                    <dl class="">
                        <dt>
                            <input type="checkbox" name="cbItem" value="@single["SendId"]" class="none" /></dt>
                        <dd class="msgcon msgsend">
                            <div>
                                收件人：<span class="blue">@SYH.Public.BLL.Public_MessagesReceivers.GetReceivers(single["MailID"])</span><span class=" gray ml10 mr10">@Common.TypeParse.ObjectToDateTime(single["CreateTime"], DateTime.Now).ToString("yyyy-MM-dd")
                                </span>
                            </div>
                            <div class="">
                                <span class="title f14 fb">
                                    @SYH.Public.BLL.Public_Messages.GetType(single["TypeId"])</span> <a href='/User/Message/MessageDetail?type=sender&id=@single["Id"]'
                                        target="_blank">
                                        @single["Title"]</a>
                            </div>
                        </dd>
                        <dd class="close" style="display: none;">
                            <a href="###" title="关闭" onclick="nDelete(@single["SendId"])"></a>
                        </dd>
                    </dl>
                    }
        </div>
        <div class="action-bar mt10 border-none">
            <p class="fd-left">
                <input name="ckAll" type="checkbox" value="" class="fd-left mr5 mt3 txt3" />
                <span class="fd-left mr10">全选</span> <span class="gray-btn fd-left ml10"><a href="#"
                    class="wh01 h17" onclick="deleteMore();">删除</a></span>
            </p>
            <p class="fd-right">
               
            </p>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            //全选
            $("input[name='ckAll']").click(function () {
                if ($(this).attr("checked") == "checked") {
                    $("input[name='cbItem']").attr("checked", "checked");
                } else {
                    $("input[name='cbItem']").removeAttr("checked");
                }
            });
        });

        //删除一个
        function nDelete(id) {
            jQuery.dialogHelper.confirm('删除之后将无法恢复，确认删除！', 'okDelete(' + id + ')');
        }

        //删除多个
        function deleteMore() {
            var obj = "";
            $("input[name='cbItem']:checked").each(function () {
                obj += $(this).val() + ",";
            });
            if (obj.length == 0) {
                jQuery.dialogHelper.alert("请先选择要删除的产品，然后点击删除！", "alert");
            }
            else {
                obj = obj.substring(0, obj.length - 1);
                jQuery.dialogHelper.confirm('删除之后将无法恢复，确认删除！', 'okDelete(\'' + obj + '\')');
            }
        }

        //确定删除
        function okDelete(id) {
            $.ajax({
                type: "POST",
                url: "/User/Message/DeleteSender",
                dataType: "text",
                data: { "action": "delete", "id": id },
                success: function (msg) {
                    var result = msg.split('|');
                    if (result[0] == 1) {
                        jQuery.dialogHelper.alert(result[1], "success", "okSuccess");
                    }
                    else if (result[0] == 0) {
                        jQuery.dialogHelper.alert(result[1], "alert");
                    }
                },
                error: function () {
                    jQuery.dialogHelper.alert("网络忙，请稍后再试！", "alert");
                }
            });
        }

        //删除成功
        function okSuccess() {
            $.dialogHelper.close();
            location.reload();
        }
      </script>
</body>
</html>
